package com.sgb.kjwl.di.carrierDemand;

import androidx.lifecycle.ViewModelProvider;

import com.sgb.kjwl.repository.HomeRepertory;
import com.sgb.kjwl.repository.impl.HomeRepertoryImpl;
import com.sgb.kjwl.view.ui.activity.carrierDemand.CarrierDemandActivity;
import com.sgb.kjwl.view.ui.fragment.home.CarrierDemandFragment;
import com.sgb.kjwl.view.ui.fragment.home.FindCarMapAndListFragment;
import com.sgb.kjwl.viewmodel.carrierDemand.CarrierDemandAtvModel;
import com.sgb.kjwl.viewmodel.carrierDemand.CarrierDemandFtvModel;
import com.sgb.kjwl.viewmodel.carrierDemand.FindCarMapAndListModel;
import com.swgk.core.base.BaseViewModel;
import com.swgk.core.base.di.Activity;
import com.swgk.core.base.di.Fragment;
import com.swgk.core.base.api.BaseApiSource;
import com.swgk.core.base.model.preference.BasePreferenceSource;

import dagger.Module;
import dagger.Provides;

@Module
public class CarrierDemandModule extends BaseViewModel {

    private CarrierDemandActivity carrierDemandActivity;
    private CarrierDemandFragment carrierDemandFragment;
    private FindCarMapAndListFragment findCarMapAndListFragment;

    public CarrierDemandModule(CarrierDemandActivity carrierDemandActivity) {
        this.carrierDemandActivity = carrierDemandActivity;
    }

    public CarrierDemandModule(CarrierDemandFragment carrierDemandFragment) {
        this.carrierDemandFragment = carrierDemandFragment;
    }

    public CarrierDemandModule(FindCarMapAndListFragment findCarMapAndListFragment) {
        this.findCarMapAndListFragment = findCarMapAndListFragment;
    }


    @Provides
    @Activity
    HomeRepertory provideHomeRepertory(BaseApiSource apiSource, BasePreferenceSource preferenceSource) {
        return new HomeRepertoryImpl(apiSource, preferenceSource);
    }


    @Provides
    @Activity
    CarrierDemandAtvModel provideCarrierDemandAtvModel(HomeRepertory repertory) {
        return new CarrierDemandAtvModel(carrierDemandActivity, repertory);
    }


    @Provides
    @Activity
    CarrierDemandFtvModel provideCarrierDemandFtvModel(HomeRepertory repertory) {
        return new ViewModelProvider(carrierDemandFragment).get(CarrierDemandFtvModel.class);
    }

    @Provides
    @Activity
    FindCarMapAndListModel provideFindCarMapAndListModel(HomeRepertory repertory) {
        return new ViewModelProvider(findCarMapAndListFragment).get(FindCarMapAndListModel.class);
    }



}
